<?php

namespace app\api\controller;

use library\File;

class UploadController extends BaseApiController
{
    /**
     * @return void
     * @throws \think\Exception
     * @throws \think\exception\PDOException
     */
    public function uploadImage()
    {
        $file = $this->request->file('file');
        $extend = pathinfo($file->getInfo('name'), PATHINFO_EXTENSION);
        $name = File::name($file->getPathname(), $extend, '', 'md5_file');
        $info = File::instance(sysconf('storage_type'))->save($name, file_get_contents($file->getRealPath()));
        $this->successReturn($info['url']);
    }

}